
import argparse
import sys

_prog_name = "arcalvus"
_description = "CLI password manager"
_epilog = "v2.0.0"

parser = argparse.ArgumentParser(
    prog=_prog_name,
    description=_description,
    epilog=_epilog)

group1 = parser.add_argument_group()
group2 = parser.add_argument_group()
group3 = parser.add_argument_group()
group4 = parser.add_argument_group()

group1.add_argument('-p', '--get-password', action="store_true")
group1.add_argument('-l', '--get-login', action="store_true")
group1.add_argument('--get-mail', action="store_true")
group1.add_argument('-o', '--get-otp', action="store_true")
group1.add_argument('-g', "--get", metavar="<Key>")

group2.add_argument('--create',
                        metavar="<Name>",
                        type=str,
                        default=None,
                        help="Create new storage")

group2.add_argument('--export-storage',
                        action="store_true",
                        help="Export for storage")
group2.add_argument('--import-storage',
                        metavar="<PATH>",
                        type=str,
                        help="Import in storage")

group3.add_argument('--edit', action="store_true", help="Open Storage")
group3.add_argument('--open', action="store_true", help="Open Storage")
group3.add_argument('--show', action="store_true", help="Show output ignore protected")

group4.add_argument('--edit-config', action="store_true", help="Open config editor.")
group4.add_argument('--set-gpg-key', metavar="<FPR>", help="Set use gpg-key.")


args, unknown_args = parser.parse_known_args()

"""
Пытаюсь разобраться с неправильными аргументами.
"""
try:
    if "-" in str(unknown_args[0])[0]:
        print("Most likely, you have entered the wrong argument, check `--help`.", file=sys.stderr)
        sys.exit(1)

except IndexError:
    unknown_args = [None]
except Exception as error:
    print(f"ARGS: `Unknown error`\n`{error}`.", file=sys.stderr)
    sys.exit(1)

if len(sys.argv) <= 1:
    sys.exit()
